<%@ page language="java" import="java.util.*" pageEncoding="utf-8" isELIgnored="false"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
 <%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt"%> 
 <%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions" %> 
 <%@ taglib prefix="s" uri="http://www.springframework.org/tags" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head> 
    <link rel="stylesheet" href="<s:url value="/resources"/>/css/common.css" type="text/css" />   
    <link rel="stylesheet" href="<s:url value="/resources"/>/css/innerstyle.css" type="text/css" />
    <link rel="stylesheet" type="text/css" media="screen" href="<s:url value="/resources"/>/css/cupertino/jquery-ui.custom.min.css" />
	<script type="text/javascript" src="<s:url value="/resources"/>/js/jquery-1.7.2.min.js"></script>
	<script type="text/javascript" src="<s:url value="/resources"/>/js/jquery-ui.custom.min.js"></script> 
	<script type="text/javascript" src="<s:url value="/resources"/>/js/jquery.form.js"></script>
	<script type="text/javascript" src="<s:url value="/resources"/>/js/json2.js"></script>
	<script type="text/javascript" src="<s:url value="/resources"/>/js/jquery.validate.js"></script>
	<script type="text/javascript" src="<s:url value="/resources"/>/js/jquery.metadata.js"></script>
	<script type="text/javascript" src="<s:url value="/resources"/>/js/messages_zh.js"></script>
<style type="text/css">
	label.error {  
	        color: red;/*错误信息的颜色*/  
	    }  
	input.error {  
	        border:1px dotted red;/*输入错误的输入框的边框样式*/  
	    }	
</style>
<script type='text/javascript'>
	$(function(){ 
	    $("#but1").button();
	    $("#but2").button(); 
	    $("#but3").button(); 
	    jiaoyan();
	    $( "#dialog-confirm" ).dialog({
            autoOpen: false,            
			resizable: false,
			height:140,
			modal: true,
			buttons: {
				"确认": function() {
				     save();
				},
				"返回": function() {
					$( this ).dialog( "close" );
				}
			}
		});  
		
		//为提交按钮绑定事件
	    $("#but1").click(function () {
             $("#dialog-confirm").dialog("open");
          });
          
        $.metadata.setType("attr", "validate");
        $("#form1").validate({});
     });
     
   //保存
	function save(){
	   if($("#form1").valid()){ 
	        var url = "<s:url value="/jydz"/>/updateDzPinp";
	         $("#form1").ajaxSubmit({
	              url:url,
	              type:'post',
	              success:function(data){
		              var ret = eval('(' + data + ')');
		              alert(ret.msg);
		              if(ret.success==true)
		              {
		                 window.location.href="<s:url value="/jydz"/>/findPinp";
		              }
	              }		              
	         });
	     }
	}
	
	//校验
	function jiaoyan()
	{
		    $.validator.addMethod("selectNone", 
	        function(value, element)
	        {   
	            if (value == "-1") 
	            {    
	                return false;    
	            }    
	            else    
	            {   
	                return true;    
	            }   
	        },    
	        "必须选择一项" 
	        ); 
	    
	         $("#form1").validate({
			       rules: {
			       "pinpmc": "required",	       
			       "meiz":{
			       	   selectNone:true
			       },
			       "pinz":{
			           selectNone:true
			       }
			       /* ,
			       "xiaxzs":{
				       required: true, 
				       number:true
			       },
			       "shangxzs":{
				       required: true, 
				       number:true
			       }  */   
			       },
				   messages: {
					   "pinpmc":"请输入品牌名称",
				       "meiz":"请选择煤种",
				       "pinz":"请选择品种"
				       /* ,
					   "xiaxzs":{
					       required: "请输入下限", 
					       number:"请输入合法数字"
				       },
					   "shangxzs":{
						   required:"请输入上限",
						   number:"请输入合法数字"
					   } */		   
				   }
			   });
	}
	
	</script>
  </head>
  
 <body>
<div id="best1">
<h2><span>新增品牌</span></h2>
<form name="form1" id="form1">
<table id="list_search" cellpadding="0" cellspacing="0" border="0">
        
		<tr>
		    <td>
            	品牌名称:<span style="color: red;font-size:16px;vertical-align:middle;">*</span>
            </td>
            <td>
            	<input type="text" name="pinpmc" class="longtextbox" value="${pinp[0].pinpmc}"/> 
            	<input type="hidden" name="sysid" class="longtextbox" value="${pinp[0].sysid}"/>
            	<input type="hidden" name="shenqsj" class="longtextbox" value="${pinp[0].shenqsj}"/>
            	<input type="hidden" name="userid" class="longtextbox" value="${pinp[0].userid}"/>
            	<input type="hidden" name="pinpid" class="longtextbox" value="${pinp[0].pinpid}"/>
            	<input type="hidden" name="pinpbh" class="longtextbox" value="${pinp[0].pinpbh}"/>
            	<input type="hidden" name="zhuangt" class="longtextbox" value="${pinp[0].zhuangt}"/>
            </td>
        	<td>
            	煤种:<span style="color: red;font-size:16px;vertical-align:middle;">*</span>
            </td>
            <td>
            	<div class="select">
					<div>
						<select name="meiz" style="width:180px">
							<c:forEach var="meiz" items="${meizlist}">
								<option value="${meiz.diccode}" <c:if test="${meiz.diccode==pinp[0].meiz}">selected="selected"</c:if>>${meiz.dicname}</option>
							</c:forEach>
						</select>
					</div>
				 </div>
            </td>
            <td>
                                            品种 :<span style="color: red;font-size:16px;vertical-align:middle;">*</span>
            </td>
            <td>            	 
            	<div class="select">
					<div>
						<select name="pinz" style="width:180px"">
							<c:forEach var="pinz" items="${pinzlist}">
								<option value="${pinz.diccode}"  <c:if test="${pinz.diccode==pinp[0].pinz}">selected="selected"</c:if>>${pinz.dicname}</option>
							</c:forEach>
						</select>
					</div>
				 </div>
            </td>
            
        </tr>
       <tr>
        	<td colspan="6" style="padding:3px;">
            <table id="changdi" align="center" cellpadding="0" cellspacing="0" class="content_gridview">
            <thead>
                <tr>
                    <th>煤炭指标</th>
                    <th>符号</th>
                    <th>下限<span style="color: red;font-size:16px;vertical-align:middle;">*</span></th>
                    <th>上限<span style="color: red;font-size:16px;vertical-align:middle;">*</span></th>
                    <th>单位</th>                 
                </tr>
            </thead>
            <tbody>
                <c:forEach items="${zlzblist}" var="zlzb">
                	<tr>
	                    <td><input  type="text" name="zhibmcs" class="longdisplaybox" value="${zlzb.zhibmc}" readonly="readonly"/>
	                    <input  type="hidden" name="zhibids"  value="${zlzb.zhibid}"/>
	                    </td>
	                    <td><input type="text"  name="fuhs"  class="longdisplaybox" value="${zlzb.fuh}" readonly="readonly"  ></td>
	                    <td><input  type="text" name="xiaxzs" class="textbox" value="${zlzb.xiaxz}" validate="{number:true,messages:{number:'请输入数字'}}"/></td>
	                    <td><input  type="text" name="shangxzs" class="textbox" value="${zlzb.shangxz}"  validate="{number:true,messages:{number:'请输入数字'}}"/></td>
	                    <td><input  type="text" name="danws" class="longdisplaybox"  value="${zlzb.danw}" readonly="readonly" ></td>
                   </tr>   
                </c:forEach>
            </tbody>
            </table>
            </td>
        </tr>
        <tr>
		    <td colspan="6" align="center">		    
			    <input id="but1" type="button" value="保存" />&nbsp;&nbsp;&nbsp;
			    <input id="but2" type="reset" value="重置" "/>&nbsp;&nbsp;&nbsp;
			    <input id="but3" type="button" name="" value="返回" onclick="javascript:history.back();"/>
		    </td>
        </tr>
  </table> 
</form>
</div> 
<div id="dialog-confirm" title="是否确认保存？"></div>
  </body>
</html>
